//
//  ViewController.m
//  HorizontalMenu
//
//  Created by Lj on 2016/11/13.
//  Copyright © 2016年 lj. All rights reserved.
//

#define RandomColor [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1.0]


#import "ViewController.h"
#import "HorizontalMenuView.h"


@interface ViewController ()<HorizontalMenuDelegate>
@property (nonatomic, strong) NSArray *dataArray;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self initView];
}

- (void)initView {
    self.title = @"菜单";
    
    UILabel *label = [UILabel new];
    [self.view addSubview:label];
    
    [self horizontalMenuView];
}

- (void)horizontalMenuView {    
    HorizontalMenuView *menuView = [[HorizontalMenuView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, 50)];    
    menuView.backgroundColor = RandomColor;
    menuView.delegate = self;
    self.dataArray = @[@"菜单一",@"菜单二菜单一",@"菜单三菜单一菜单一",@"菜单四",@"菜单五菜",@"菜单六菜单一菜单菜单六菜单一菜单"];
    [menuView setNameWinthArray:self.dataArray];
    [self.view addSubview:menuView];
}

#pragma mark - HorizontalMenuDelegate
- (NSArray *)horizontalMenuArray:(UIView *)menuView {
    return self.dataArray;
}


- (void)menuView:(UIView *)menuView didSelectButton:(NSUInteger)buttonSerial {
    self.view.backgroundColor = RandomColor;
    self.title = self.dataArray[buttonSerial];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
